package com.wanrue.tcc.admin.service.impl;

import com.wanrue.tcc.admin.dao.ITransactionDao;
import com.wanrue.tcc.admin.dao.impl.TransactionDao;
import com.wanrue.tcc.admin.entity.Transaction;
import com.wanrue.tcc.admin.etl.DataImport;
import com.wanrue.tcc.admin.service.ITransactionService;
import com.wanrue.tcc.admin.util.Page;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

@Service
public class TransactionService implements ITransactionService {

    @Resource
    private ITransactionDao transactionDao;

    @Override
    public void setDataImport(DataImport dataImport) {
        transactionDao.setDataImport(dataImport);
    }

    @Override
    public List<String> getServer() {
        return transactionDao.getServer();
    }

    @Override
    public Page<Transaction> findPage(Page page) {
        return transactionDao.findPage(page);
    }

    @Override
    public int update(Transaction transaction) {
        return transactionDao.update(transaction);
    }

    @Override
    public void updateCache() {
        transactionDao.updateCache();
    }

    @Override
    public Transaction findById(Long id) {
        return transactionDao.findById(id);
    }

    @Scheduled(cron = "0 */5 * * * ?")
    public void cronUpdateCache() {
        transactionDao.updateCache();
    }
}
